<?php
/**
 * Created by PhpStorm.
 * User: coolinmind
 * Date: 27/02/2019
 * Time: 10:27
 */

namespace App\Services;


use App\Modules\AdapterApi;
use App\Services\User\UserIndex;

class BaseService extends AdapterApi
{
    /**
     * 检测用户是否登录成功，
     * 如果登录成功，
     * 则返回用户信息，
     * 否则提示用户登录。
     * @param $token
     * @return array
     */
    protected function isLogin($token)
    {
        $info = $tokenContent = UserIndex::Token()->hGetAll($token);
        if (!isset($info['res']['id'])) {
            return auto_failure(null, '请登录');
        }else{
            $info['res']['other_info'] = json_decode($info['res']['other_info']);
            return $info;
        }
    }
}
